package com.j.lemon.learn.basic.thread;

public class DeadLock1 {

    private static final int a =0;
    private static  final Student s= new Student();
    public static void main(String[] args) {
        s.setAge(22);
        System.out.println(s.getAge());
        s.setAge(11);
        System.out.println(s.getAge());



        Object a = new Object();
        Object b = new Object();
        Thread t1 = new Thread(() -> {
            synchronized (a){
                System.out.println("AAAAAAAAAAAAA");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (b){
                   System.out.println("ABABABABABABABABABAB");
                }
            }



        });

        Thread t2 = new Thread(() -> {
            synchronized (b){
                System.out.println("BBBBBBBBBBBBBBBBB");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (a){
                   System.out.println("BABABABABABABABABA");
                }
            }


        });
//        t1.start();
//        t2.start();


    }
}
